package cn.liulin.java8.selfFunc;

import org.jasypt.commons.CommonUtils;

import java.util.UUID;
import java.util.concurrent.*;

/**
 * cn.liulin.java8.selfFunc$
 *
 * @author ll
 * @date 2023-06-01 09:15:09
 **/
public class ThreadPoolTest {
    public static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2, 2, 60L,
                                                TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(2), new ThreadPoolExecutor.AbortPolicy());

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            try {
                threadPoolExecutor.execute(new Runnable() {
                    public String id = UUID.randomUUID().toString();
                    @Override
                    public void run() {
                        while (true) {
                            try {
                                Thread.sleep(1000L);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            System.out.println(id);
                        }
                    }
                });
            } catch (RejectedExecutionException E) {
                System.out.println("你就是个渣渣");
            }
        }
    }
}
